package com.ruoyi.ftrl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.ftrl.domain.Dto.StationDto;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ftrl.domain.HeatInfo;
import com.ruoyi.ftrl.service.IHeatInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 热采集数据信息Controller
 * 
 * @author dihang
 * @date 2024-08-09
 */
@RestController
@RequestMapping("/ftrl/quantity")
public class HeatInfoController extends BaseController
{
    @Autowired
    private IHeatInfoService heatInfoService;

    /**
     * 供回水温度（大屏驾驶舱）
     * @return
     */
    @GetMapping("/hot")
    public TableDataInfo listHot()
    {
        List<StationDto> list = heatInfoService.selectHeatInfoListHot();
        return getDataTable(list);
    }
    /**
     * 查询热采集数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:quantity:list')")
    @GetMapping("/list")
    public TableDataInfo list(HeatInfo heatInfo)
    {
        startPage();
        List<HeatInfo> list = heatInfoService.selectHeatInfoList(heatInfo);
        return getDataTable(list);
    }

    /**
     * 导出热采集数据信息列表
     */
    @PreAuthorize("@ss.hasPermi('ftrl:quantity:export')")
    @Log(title = "热采集数据信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HeatInfo heatInfo)
    {
        List<HeatInfo> list = heatInfoService.selectHeatInfoList(heatInfo);
        ExcelUtil<HeatInfo> util = new ExcelUtil<HeatInfo>(HeatInfo.class);
        util.exportExcel(response, list, "热采集数据信息数据");
    }

    /**
     * 获取热采集数据信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:quantity:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(heatInfoService.selectHeatInfoById(id));
    }

    /**
     * 新增热采集数据信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:quantity:add')")
    @Log(title = "热采集数据信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HeatInfo heatInfo)
    {
        return toAjax(heatInfoService.insertHeatInfo(heatInfo));
    }

    /**
     * 修改热采集数据信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:quantity:edit')")
    @Log(title = "热采集数据信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HeatInfo heatInfo)
    {
        return toAjax(heatInfoService.updateHeatInfo(heatInfo));
    }

    /**
     * 删除热采集数据信息
     */
    @PreAuthorize("@ss.hasPermi('ftrl:quantity:remove')")
    @Log(title = "热采集数据信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(heatInfoService.deleteHeatInfoByIds(ids));
    }

    /**
     * 定时拉取天罡系统关于安悦佳苑的热表数据
     * @return
     */
    @PostMapping("/lists")
    public Object lists()
    {
        Object object= heatInfoService.selectHeatInfoLists();
        return object;
    }

}
